package com.xlt.activiti.one;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;

public class ActivitiSingleProcess {
    public static void singleProcees(){
        // 1.得到processEngine对象
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        // 2.runtimeService
        RuntimeService runtimeService = processEngine.getRuntimeService();
        // 3.查询运行中实例
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
                .processInstanceBusinessKey("123").singleResult();
       boolean suspended = processInstance.isSuspended();
       if (suspended){
           runtimeService.activateProcessInstanceById(processInstance.getId());
           System.out.println("流程激活");
       }else {
           runtimeService.suspendProcessInstanceById(processInstance.getId());
           System.out.println("流程挂起");
       }
    }
}
